package a11;

import static org.junit.Assert.*;

import org.junit.Test;

public class BubbleSortTest {
	
//	@Test
//	public void testUnSort(){
//System.out.println("unSortArray:\n");
//		
//		long start = System.currentTimeMillis();
//		int[] unSortArray = BubbleSort.populateArray(10000);
//		long stop = System.currentTimeMillis();
//		System.out.println(stop - start + " ms\n");
//		for (int i = 0; i<unSortArray.length-1; i++){
//		if (unSortArray[i] > unSortArray[i+1]){
//			fail();
//		}
//		}
//	}

	@Test
	public void testSort() {
		
		
		System.out.println("thouArray:\n");
		
		int[] pop = BubbleSort.populateArray(1000);
		long start = System.currentTimeMillis();
		int[] thouArray = BubbleSort.sort(pop);
		long stop = System.currentTimeMillis();
		System.out.println((stop - start)/1000. + " seconds\n");
		for (int i = 0; i<thouArray.length-1; i++){
		if (thouArray[i] > thouArray[i+1]){
			fail();
		}
		}
		
System.out.println("tenThouArray:\n");
		
		int[] pop2 = BubbleSort.populateArray(10000);
		long start2 = System.currentTimeMillis();
		int[] tenThouArray = BubbleSort.sort(pop2);
		long stop2 = System.currentTimeMillis();
		System.out.println((stop2 - start2)/1000. + " seconds\n");
		for (int i = 0; i<tenThouArray.length-1; i++){
		if (tenThouArray[i] > tenThouArray[i+1]){
			fail();
		}
		}
		
System.out.println("hunThouArray:\n");
		
		int[] pop3 = BubbleSort.populateArray(100000);
		long start3 = System.currentTimeMillis();
		int[] hunThouArray = BubbleSort.sort(pop3);
		long stop3 = System.currentTimeMillis();
		System.out.println((stop3 - start3)/1000. + " seconds\n");
		for (int i = 0; i<hunThouArray.length-1; i++){
		if (hunThouArray[i] > hunThouArray[i+1]){
			fail();
		}
		}
	}

}
